<template>
  <div>
    <search_playlist_album
      :cover_path="album_cover_path"
      :playlist_album_name="album_name"
      :author_name="album_author_name"
      :isuue_time="album_issue_time"
      :playlist_album_info="album_info"
      :follow_data="album_follow_data"
      :comment_data="album_comment_data"
      :list="list"
    />
  </div>
  <div class="page_apart_block">
    <page_apart :list="pageCnt" />
  </div>
</template>

<script>
import page_apart from "../circle_use/page_apart.vue";
import search_playlist_album from "../circle_use/search_playlist_album.vue";
export default {
  name: "search_album",
  components: {
    search_playlist_album,
    page_apart,
  },
  data() {
    return {
      album_id:0,
      album_cover_path: "",
      album_name: "",
      album_author_name: "",
      album_issue_time: "",
      album_info: "",
      album_follow_data: "",
      album_comment_data: "",
      list: [],
      pageCnt: 1, //页码总数
      flag: 1, //专辑
    };
  },
  created() {
    this.$http
      .get("/search/album", {
        params: {
          keyword: this.$route.query.keyword,
          limit: 10,
        },
      })
      .then((res) => {
        if (res.data.data.count == 0) {
          alert("空");
        } else {
          let result = res.data.data;
          this.list = result.list;
          this.album_cover_path = result.list[0].cover;
          this.album_name = result.list[0].name;
          this.album_author_name = result.list[0].author;
          this.album_issue_time = result.list[0].publish;
          this.album_info = result.list[0].description;
          this.album_follow_data = JSON.stringify(result.list[0].fans);
          this.album_comment_data = JSON.stringify(result.list[0].comments);
          this.pageCnt = Math.ceil(result.count / 8 - 1);
        }
      });
  },
  methods: {
    pageGet(index) {
      this.$http
        .get("/search/album", {
          params: {
            keyword: this.$route.query.keyword,
            limit: 10,
            page: index,
          },
        })
        .then((res) => {
          let result = res.data.data;
          this.album_list = result.list;
          this.album_cover_path = result.list[0].cover;
          this.album_name = result.list[0].name;
          this.album_author_name = result.list[0].author;
          this.album_issue_time = result.list[0].publish;
          this.album_info = result.list[0].description;
          this.album_follow_data = JSON.stringify(result.list[0].fans);
          this.album_comment_data = JSON.stringify(result.list[0].comments);
        });
    },
  },
};
</script>

<style scoped>
.search_playlist_album >>> .cover_box {
  border-radius: 76px;
}
.page_apart_block {
  padding-top: 44px;
}
</style>